<?php
function smarty_modifier_text2tag($sText, $sClass='')
{
    $sTagHost = "http://tag.tudou.com";
    $sText = ereg_replace("\s+", " ", $sText);
    $rOut = array();
    foreach (explode(' ', $sText) as $sTag) {
        $rOut[] = '<a href="'.$sTagHost.'/'.urlencode($sTag).'"'.($sClass ? ' class="'.$sClass.'"' : '').' target="_blank">'.htmlspecialchars($sTag).'</a>';
    }
    return implode(' ', $rOut);
}
?>
